package vista;
import com.cloudgarden.layout.AnchorLayout;

import contoladores.CListadoIngredientesMasUsados;
import contoladores.CListadoProductosVendidos;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VListadoProductosVendidos extends javax.swing.JFrame {
	private JLabel jLblcod_categoria;
	private JLabel jLblDescripcion;
	private JTable jTable1;
	private DefaultTableModel modeloTabla;
    private Vector<String> fila;
    private CListadoProductosVendidos control;
    private JButton Salir;
    private JRadioButton jRadioDes;
    private JRadioButton jRadioAsc;
    private JLabel jLabel1;
    private JButton jButtonListar;
    

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VListadoProductosVendidos inst = new VListadoProductosVendidos();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VListadoProductosVendidos() {
		super();
		initGUI();
		
	}
	private void initGUI() {
		{
			getContentPane().setLayout(null);
			this.setTitle("Listado de Productos");
		}
		{
			TableModel jTable1Model = 
				new DefaultTableModel(
						new String[][] { { "One", "Two" }, { "Three", "Four" } },
						new String[] { "Column 1", "Column 2" });
			jTable1 = new JTable();
			getContentPane().add(jTable1);
			jTable1.setModel(jTable1Model);
			jTable1.setBounds(30, 58, 438, 232);
		}
		{
			jButtonListar = new JButton();
			getContentPane().add(jButtonListar);
			jButtonListar.setText("Listar");
			jButtonListar.setActionCommand("Listar");
			jButtonListar.setBounds(370, 21, 101, 22);
		}
		{
			jLabel1 = new JLabel();
			getContentPane().add(jLabel1);
			jLabel1.setText("Ordenar:");
			jLabel1.setBounds(12, 24, 92, 15);
		}
		{
			jRadioAsc = new JRadioButton();
			getContentPane().add(jRadioAsc);
			jRadioAsc.setText("Ascendente");
			jRadioAsc.setActionCommand("Asc");
			jRadioAsc.setBounds(107, 22, 125, 19);
		}
		{
			jRadioDes = new JRadioButton();
			getContentPane().add(jRadioDes);
			jRadioDes.setText("Descendente");
			jRadioDes.setActionCommand("Des");
			jRadioDes.setBounds(237, 22, 128, 19);
		}
		{
			Salir = new JButton();
			getContentPane().add(Salir);
			Salir.setText("Salir");
			Salir.setActionCommand("Salir");
			Salir.setBounds(366, 343, 111, 22);
		}
		{
			this.setSize(513, 418);
		}
		
		modeloTabla= new DefaultTableModel();
		 jTable1.setModel(modeloTabla);

	        fila= new Vector<String>();

	        fila.add("Producto");
	        fila.add("Ingreso Generado");
	        fila.add("Cantidad Vendida");
	        modeloTabla.setColumnIdentifiers(fila);
	        control=new CListadoProductosVendidos(this);
	}
	
	public void addListener(ActionListener escuchador){
		Salir.addActionListener(escuchador);
		jButtonListar.addActionListener(escuchador);
		jRadioAsc.addActionListener(escuchador);
		jRadioDes.addActionListener(escuchador);
	}

	public DefaultTableModel getModeloTabla() {
		return modeloTabla;
	}

	public void setModeloTabla(DefaultTableModel modeloTabla) {
		this.modeloTabla = modeloTabla;
	}


	public void agregar(String[] strings) {
		fila= new Vector<String>();
		for (int i = 0; i < strings.length; i++) {

		       fila.add(strings[i]);	
		}

               modeloTabla.addRow(fila);
		
	}}
